package cn.ddiancan.schedule.business.service.impl;

import cn.ddiancan.schedule.base.domain.TaskDTO;
import cn.ddiancan.schedule.business.service.AbastractScheduleExecutor;
import cn.ddiancan.schedule.utils.HttpRestTemplateBuilder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

@Slf4j
@Service("remoteTaskExecutor")
public class URIExecutor extends AbastractScheduleExecutor {

    @Override
    public void execute(TaskDTO taskDTO, Runnable runnable) {
        ResponseEntity<String> exchange = HttpRestTemplateBuilder.getRestTemplate()
            .exchange(taskDTO.getExecuteUrl(), HttpMethod.GET, null, String.class);
        log.info("execute task {} result {}", taskDTO, exchange.getBody());
    }
}
